<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns:ui="http://java.sun.com/jsf/facelets"	
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:h="http://java.sun.com/jsf/html"	
	xmlns:c="http://java.sun.com/jsp/jstl/core"
	xmlns:ace="http://www.icefaces.org/icefaces/components">
	
	<ace:confirmationDialog  widgetVar="confirmation"
                             message="Удалить пользователя?"
                             header="Внимание"
                             width="360"
                             height="180"
                             closable="true"
                             position="center">
         <h:panelGrid columns="2" styleClass="centeredPanelGrid">
             <h:commandButton value="Да" onclick="confirmation.hide()" actionListener="#{personBean.delete}"/>
             <h:commandButton value="Нет" onclick="confirmation.hide()" />
         </h:panelGrid>
     </ace:confirmationDialog>
	
	<h:panelGrid columns="2">
		<ace:pushButton value="Добавить" actionListener="#{personBean.add}"/>		
		<ace:pushButton value="Удалить" styleClass="ice-pushbutton ui-state-disabled" rendered="#{!personBean.isSelected}"/>
		<ace:pushButton value="Удалить" styleClass="ice-pushbutton" rendered="#{personBean.isSelected}" onclick="confirmation.show()"/>		
	</h:panelGrid>
	
	<ace:dataTable id="gridPersons" value="#{personBean.items}" 
					var="person"					 
					paginator="true" 
					paginatorPosition="bottom"
					reorderableColumns="true"
					rows="20"
					stateMap="#{personBean.stateMap}"	
					selectionMode="single"
					rowSelectListener="#{personBean.select}"
					rowUnSelectListener="#{personBean.unselect}">
 			 <ace:column id="id" headerText="ID" sortBy="#{person.id}" filterBy="#{person.id}" filterMatchMode="exact">
              	<h:outputText id="idCell" value="#{person.id}"/>
              </ace:column>                 
              <ace:column id="lastname" headerText="Фамилия" sortBy="#{person.lastname}" filterBy="#{person.lastname}">
              	<ace:cellEditor>
                  	<f:facet name="output">
                      	<h:outputText id="lastnameCell" value="#{person.lastname}"/>
                   	</f:facet>
                   	<f:facet name="input">
                       	<h:inputText id="lastnameInput" value="#{person.lastname}" required="true"/>
                   	</f:facet>
                </ace:cellEditor>              	
              </ace:column>
              <ace:column id="firstname" headerText="Имя" sortBy="#{person.firstname}" filterBy="#{person.firstname}">
              	<ace:cellEditor>
                  	<f:facet name="output">
                      	<h:outputText id="firstnameCell" value="#{person.firstname}"/>
                   	</f:facet>
                   	<f:facet name="input">
                       	<h:inputText id="firslnameInput" value="#{person.firstname}" required="true"/>
                   	</f:facet>
                </ace:cellEditor>              	
              </ace:column>
              <ace:column id="middlename" headerText="Отчество" sortBy="#{person.middlename}" filterBy="#{person.middlename}">
              	<ace:cellEditor>
                  	<f:facet name="output">
                      	<h:outputText id="middlenameCell" value="#{person.middlename}"/>
                   	</f:facet>
                   	<f:facet name="input">
                       	<h:inputText id="midllenameInput" value="#{person.middlename}"/>
                   	</f:facet>
                </ace:cellEditor>
              </ace:column>
              <ace:column id="login" headerText="Логин" sortBy="#{person.login}" filterBy="#{person.login}">
              	<ace:cellEditor>
                  	<f:facet name="output">
                      	<h:outputText id="loginCell" value="#{person.login}"/>
                   	</f:facet>
                   	<f:facet name="input">
                       	<h:inputText id="loginInput" value="#{person.login}" required="true"/>                       	
                   	</f:facet>
                </ace:cellEditor>
              </ace:column>           
              <ace:column id="password" headerText="Пароль">
              	<ace:cellEditor>
                  	<f:facet name="output">
                      	<h:outputText id="passwordCell" value="***"/>
                   	</f:facet>
                   	<f:facet name="input">
                       	<h:inputSecret id="passwordInput" value="#{person.password}"/>
                   	</f:facet>
                </ace:cellEditor>              	
              </ace:column>
              <ace:column id="isadmin" headerText="Администратор" sortBy="#{person.isAdmin}">
              	<ace:cellEditor>
                  	<f:facet name="output">
                      	<h:panelGroup rendered="false" styleClass="#{person.isAdmin ? 'ui-icon ui-icon-check' : ''}"/>                      	                      	                      	
                   	</f:facet>
                   	<f:facet name="input">
                       	<h:selectBooleanCheckbox id="isadminInput" value="#{person.isAdmin}"/>
                   	</f:facet>
                </ace:cellEditor>
              </ace:column>
              <ace:column id="misc">
              	<ace:rowEditor id="editor" 
              		rowEditListener="#{personBean.edit}"               		
              		cancelTitle="Отмена" 
              		startTitle="Редактировать" 
              		submitTitle="Сохранить"/>                   		
              </ace:column>                             
       	</ace:dataTable>

</ui:composition>
